import enum_data.FormStatus;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class Form_Tovar extends JDialog {
    private JPanel contentPane;
    private JButton buttonOK;
    private JButton buttonCancel;
    private JTabbedPane tabbedPane1;
    private JTextField txtProd_ProdName;
    private JTextField textField2;
    private JTextField textField3;
    private JTextField textField4;
    private JButton btn_Proizv;
    private JButton btn_TradeMark;
    private JButton btn_Product;
    private JComboBox comboBox1;
    private JComboBox comboBox2;
    private JComboBox comboBox3;

    private int sizeWidth = 500;
    private int sizeHeight = 270;

    String userID;
    FormStatus formMode;

    public Form_Tovar() {
        // Form_User(String userID, FormStatus formMode)

        this.userID = "1";
        this.formMode = FormStatus.NEW;

        this.setSize(sizeWidth, sizeHeight);

        //Размещаем окно по центру экрана
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        int locationX = (screenSize.width - sizeWidth) / 2;
        int locationY = (screenSize.height - sizeHeight) / 2;
        setBounds(locationX, locationY, sizeWidth, sizeHeight);

        setContentPane(contentPane);
        setModal(true);

        if(this.formMode == FormStatus.NEW){
            txtProd_ProdName.setEnabled(true);
        }

        txtProd_ProdName.add(new Button("SSS"));


        getRootPane().setDefaultButton(buttonOK);

        buttonOK.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                onOK();
            }
        });

        buttonCancel.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                onCancel();
            }
        });

// call onCancel() when cross is clicked
        setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
        addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                onCancel();
            }
        });

// call onCancel() on ESCAPE
        contentPane.registerKeyboardAction(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                onCancel();
            }
        }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    }

    private void onOK() {
// add your code here
        dispose();
    }

    private void onCancel() {
// add your code here if necessary
        dispose();
    }

//    public static void main(String[] args) {
//        Form_Tovar dialog = new Form_Tovar();
//        dialog.pack();
//        dialog.setVisible(true);
//        System.exit(0);
//    }
}
